﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using RATSharp.Rest;

namespace RATSharpW7.View
{
    /// <summary>
    /// Pop-up window layout for object search.
    /// </summary>
    public partial class SearchControl : UserControl
    {
        public event EventHandler Close;
        
        /// <summary>
        /// search control result
        /// </summary>
        public SearchBy selectedSearchBy { get; set; }

        public SearchControl()
        {
            InitializeComponent();
            //dafault value
            selectedSearchBy = SearchBy.ALL;
        }

        private void close_Click(object sender, RoutedEventArgs e)
        {            
            if (Close != null)
            {
                Close(this, new EventArgs());
            }
        }

        private void searchby_click(object sender, RoutedEventArgs e)
        {
            if (Convert.ToBoolean(radioButtonAll.IsChecked))
            {
                selectedSearchBy = SearchBy.ALL;
            }

            else if (Convert.ToBoolean(radioButtonClass.IsChecked))
            {
                selectedSearchBy = SearchBy.CLASS_NAME;
            }

            else if (Convert.ToBoolean(radioButtonDescription.IsChecked))
            {
                selectedSearchBy = SearchBy.OBJ_DESCRIPTION;

            }
            else if (Convert.ToBoolean(radioButtonName.IsChecked))
            {
                selectedSearchBy = SearchBy.OBJ_NAME;
            }
        }
    }
}
